package com.guo.boot.study.syn;

import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @Auther Heart Guo
 * @Date 2021/12/23-16:15
 */
/*
       测试JUC安全类型的集合
* */
public class TestJUC {
    public static void main(String[] args) throws InterruptedException {
        CopyOnWriteArrayList<String> list = new CopyOnWriteArrayList();
        for (int i = 0; i < 10000; i++) {
            new Thread(() ->{
                list.add(Thread.currentThread().getName());
            }).start();
        }
        Thread.sleep(3000);
        System.out.println(list.size());
    }
}
